package com.ssm.service.log.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ssm.common.Message;
import com.ssm.common.db.IdPrefix;
import com.ssm.common.db.SequenceId;
import com.ssm.dao.log.SystemLogDao;
import com.ssm.entity.log.SystemLog;
import com.ssm.service.BaseService;
import com.ssm.service.log.SystemLogService;
import com.ssm.web.Page;

@Service
public class SystemLogServiceImpl extends BaseService implements SystemLogService {
	
	@Autowired
	private SystemLogDao systemLogDao;

	@Override
	public Page<SystemLog> queryList(SystemLog systemLog) {
		Page<SystemLog> page = new Page<>();
		page.setCount(systemLogDao.queryCount(systemLog));
		page.setRecord(systemLogDao.queryList(systemLog));
		page.setCurrentPage(systemLog.getCurrentPage());
		return page;
	}

	@Override
	@Transactional
	public Message save(SystemLog systemLog) {
		Message message = new Message();
		try {
			systemLog.setId(getId(SequenceId.SYSTEM_LOG, IdPrefix.SYSTEM_LOG, 10));
			systemLogDao.save(systemLog);
		} catch (Exception e) {
			e.printStackTrace();
			message.setSuccess(false);
			message.setMessage("新增失败");
		}
		return message;
	}
}
